package com.atguigu.functions;

import com.atguigu.bean.WaterSensor;
import org.apache.flink.api.common.functions.MapFunction;

/**
 * @author gmd
 * @desc MapFunction接口实现类，自定义Map映射算子的业务逻辑。将String类映射为WaterSensor类
 * @since 2024-11-24 10:29:04
 */
public class MapFunction2Impl implements MapFunction<String, WaterSensor> {

    @Override
    public WaterSensor map(String value) throws Exception {
        String[] dataArr = value.split(",");
        // System.out.println("====== MapFunction2Impl: id=" + dataArr[0] + ",ts=" + dataArr[1] + ",vc=" + dataArr[2]);
        return new WaterSensor(dataArr[0], Long.valueOf(dataArr[1]), Integer.valueOf(dataArr[2]));
    }

}
